open Tokens
open Glob
open Lexing
open Printf

let localisation posD posF =
  let l = posD.pos_lnum in
  let deb = posD.pos_cnum - posD.pos_bol + 1 in
  let fin = posF.pos_cnum - posF.pos_bol + 1 in
  eprintf "File \"lapin\", line %d, characters %d-%d:\n" l deb fin;;
let lexbuf = ref (Lexing.from_string "") in
try
  lexbuf := Lexing.from_channel stdin;
  Grammar.program Tokens.token (!lexbuf)
with  Grammar.Error -> 
    localisation (Lexing.lexeme_start_p (!lexbuf)) 
      (Lexing.lexeme_start_p (!lexbuf));
    eprintf "Syntax error @.";
    exit 1;;

liste:=purify (!liste);
print_int ((List.length (!liste)) - (!nbInstr));
print_string "\n";
print (!liste);;
  
